package com.simple.cloud.service;

import com.simple.cloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <h3>springcloud</h3>
 * <p></p>
 *
 * @author : 你的名字
 * @date : 2020-05-26 08:57
 **/
//降级~
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory {
    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public Dept queryById(Long id) {
                return new Dept()
                        .setDeptno(id)
                        .setDname("id=>"+id+"没有对应的信息，客户端提供了降级的信息，这个服务现在已经被关闭")
                        .setDbSource("没有数据~");
            }
            @Override
            public List<Dept> queryAll() {
                return null;
            }
            @Override
            public boolean addDept(Dept dept) {
                return false;
            }
        };
    }
}
